const tableData = [
  {
    id: 1,
    projectName: '百度一下',
    projectType: '1',
    projectTypeName: '百度百科',
    address: 'https://www.baidu.com/',
    uploadTime: '2016-05-03',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    state: '1',
    userArr: ['1'],
    mark: '备注9999',
    firstDep: '01',
    secondDep: '0102',
    files: [
      {
        fileAddress:
          'http://th1-oss.bimfound.cn/FileManage/202409/23/docx%25E6%25B5%258B%25E8%25AF%2595%25E9%2599%2584%25E4%25BB%25B6.docx',
        fileId: 18548609354949,
        fileName: 'docx测试附件.docx',
        fileType: null,
        size: 11624,
        icon: 'docx',
        state: 0,
        uploadDate: '2024-09-23 15:23:32',
      },
      {
        fileAddress:
          'http://th1-oss.bimfound.cn/FileManage/202409/23/xlsx%25E6%25B5%258B%25E8%25AF%2595.xlsx',
        fileId: 18548609989445,
        fileName: 'xlsx测试.xlsx',
        icon: 'xlsx',
        fileType: null,
        size: 9965,
        state: 0,
        uploadDate: '2024-09-23 15:23:37',
      },
      {
        fileAddress:
          'http://th1-oss.bimfound.cn/FileManage/202409/23/%25E6%25B5%258B%25E8%25AF%2595%25E9%2599%2584%25E4%25BB%25B622.png',
        fileId: 18548610584645,
        fileName: '测试附件22.png',
        fileType: null,
        icon: 'png',
        size: 632576,
        state: 0,
        uploadDate: '2024-09-23 15:23:42',
      },
      {
        fileAddress:
          'http://th1-oss.bimfound.cn/FileManage/202409/23/%25E6%25B5%258B%25E8%25AF%2595%25E6%2596%2587%25E6%259C%25AC%25E6%2596%2587%25E6%25A1%25A3(1).txt',
        fileId: 18548611184709,
        fileName: '测试文本文档.txt',
        fileType: null,
        icon: 'txt',
        size: 12,
        state: 0,
        uploadDate: '2024-09-23 15:23:46',
      },
    ],
  },
  {
    id: 2,
    projectName: '淘宝',
    projectType: '2',
    projectTypeName: '网购商城',
    uploadTime: '2016-05-02',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://www.taobao.com/',
    userArr: ['1', '2'],
    state: '1',
    mark: '',
    firstDep: '',
    secondDep: '',
  },
  {
    id: 3,
    projectName: '京东',
    projectType: '2',
    projectTypeName: '网购商城',
    uploadTime: '2016-05-04',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://www.jd.com/',
    userArr: ['4', '5', '6'],
    state: '1',
  },
  {
    id: 4,
    projectName: '暴雪',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 5,
    projectName: '暴雪1122',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '0',
  },
  {
    id: 6,
    projectName: '暴雪1',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 7,
    projectName: '暴雪2',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '0',
  },
  {
    id: 8,
    projectName: '暴雪3',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '0',
  },
  {
    id: 9,
    projectName: '暴雪4',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 10,
    projectName: '暴雪5',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 11,
    projectName: '暴雪6',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 12,
    projectName: '暴雪7',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 13,
    projectName: '暴雪8',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 14,
    projectName: '暴雪9',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 15,
    projectName: '暴雪10',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 16,
    projectName: '暴雪11',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 17,
    projectName: '暴雪12',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 18,
    projectName: '暴雪13',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 19,
    projectName: '暴雪14',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 20,
    projectName: '暴雪15',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
  {
    id: 21,
    projectName: '暴雪16',
    projectType: '3',
    projectTypeName: '游戏',
    uploadTime: '2016-05-01',
    uploadTimeArr: ['2016-05-03', '2024-05-03'],
    address: 'https://us.shop.battle.net/zh-tw',
    userArr: ['1', '2', '3', '4', '5', '6'],
    state: '1',
  },
];

//查询列表数据接口
export const getTableDataAPI = (param: any = {}) => {
  let arrData = [];
  const { currentPage, pageSize, ...obj } = param;
  const keys = Object.keys(obj);
  if (keys.length) {
    keys.forEach((key) => {
      if (typeof obj[key] !== 'object') {
        let arr = [];
        arr = tableData.filter((item) => item[key] === obj[key]);
        arrData = [...arrData, ...arr];
      }
    });
  } else {
    arrData = tableData;
  }
  const resultData = arrData.slice((currentPage - 1) * pageSize, currentPage * pageSize);

  return Promise.resolve({
    code: 200,
    message: '操作成功',
    result: resultData,
    total: arrData.length,
  });
};

// 新增数据接口
export const addTableDataAPI = (param: any = {}) => {
  tableData.unshift({
    ...param,
    id: tableData.length + 1,
  });
  return Promise.resolve({
    code: 200,
    message: '操作成功',
    result: {},
  });
};

// 编辑数据接口
export const editTableDataAPI = (param: any = {}) => {
  const { id } = param;
  const index = tableData.findIndex((item) => item.id === id);
  tableData[index] = param;
  return Promise.resolve({
    code: 200,
    message: '操作成功',
    result: {},
  });
};

// 删除数据接口
export const delTableDataAPI = (id: number) => {
  const index = tableData.findIndex((item) => item.id === id);
  tableData.splice(index, 1);
  return Promise.resolve({
    code: 200,
    message: '操作成功',
    result: {},
  });
};
